﻿using Admin.Util;
using Microsoft.AspNetCore.Mvc.Filters;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Admin.Core
{
    /// <summary>
    /// 用户管理接口
    /// </summary>
    public interface IOperator
    {
        /// <summary>
        /// 获取用户 Id
        /// </summary>
        string UserId { get; }

        /// <summary>
        /// 获取用户信息
        /// </summary>
        BaseUser User { get; }

        /// <summary>
        /// 检查用户是否有效
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<BaseUser> CheckUserAsync(string userId);

        /// <summary>
        /// 查询用户权限
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        Task<List<BaseSecurity>> GetSecuritiesAsync(string userId);

        /// <summary>
        /// 查询用户角色
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <returns></returns>
        Task<List<BaseRole>> GetRolesAsync(string userId);

        /// <summary>
        /// 记录操作日志
        /// </summary>
        /// <param name="msg">内容</param>
        Task WriteUserLog(string msg);
        Task WriteUserLog(ActionExecutingContext context,
            ActionExecutionDelegate next);
    }
}